<div class="container">
            <div class="row">
                <div class="col-md-12">
                    <div class="titlepage">
                        <h2>搜索商品</h2>
                    </div>
                </div>
            </div>
        </div>
        <div class="brand-bg">
            <div class="container">
				<div class="search-item-shop col-md-12">
					<form>
						<input class="search" type="text" name="" placeholder="搜素商品"/>
						<button id="search-item" class="search-button" type="button">搜索商品</button>
					</form>
				</div>
				<div class="item-class-list">
					<p class="item-class-name">
						商品分类
					</p>

				</div>
				<div class="row cat-items">

            	</div>
        	</div>
		</div>
<script type="text/javascript" src="js/ry/item.js"></script>
<script type="text/javascript">
	$(function (){
		let url =`/ruoyi/search/getitems`;
		doLoadGetCats();
		doLoadGetSearchItems(url);

	});
	function doLoadGetCats(){
		let url =`/ruoyi/search/getcats`;
		$.ajax({
			url:url,
			dataType:"json",
			success(result){
				if (result.status===200){
					doLoadCats(result.data);
					doClickCats();
					doClickSearchItems();
				}
			}
		});
	}
	function doLoadGetSearchItems(url){
		$.ajax({
			url:url,
			dataType:"json",
			success(result){
				if (result.status===200){
					doLoadSearchItems(result.data);
					doLoadClick();
				}
			}
		});
	}
	function doLoadCats(cats){
		for (let i in cats) {
			$(".item-class-list").append(doLoadCreateCats(cats[i]));
		}
	}
	function doLoadCreateCats(cat){
		return `<div><span class="hidden-val">${cat.catId}</span>${cat.catName}</div>`;
	}
	function doLoadSearchItems(items){
		for (let i in items) {
			$(".cat-items").append(doCreateSearchItems(items[i]));
		}
	}
	function doCreateSearchItems(item){
		return `<div class="col-xl-4 col-lg-4 col-md-4 col-sm-6 margin">
					<div class="item_box">
						<div class="item-name">
							<p class="hidden-val">${item.itemId}</p>
							<img src="${item.image}">
							<p>${item.title}</p>
							<p>价格: <span>${item.price}</span></p>
						</div>
						<div class="item-shop">
							<p class="hidden-val">${item.shopId}</p>
							<img src="${item.logo}" />
							<div>${item.shopName}</div>
						</div>
					</div>
				</div>`;
	}
</script>